home *** CD-ROM | disk | FTP | other *** search
/ GameStar 2004 April / Gamestar_61_2004-04_dvdb.iso / DVDStar / Editace / hltp.exe / {app} / Applications / QuArK / plugins / mapcaulk.py < prev    next >
Text File  |  2004-01-05  |  4KB  |  126 lines

  1. """   QuArK  -  Quake Army Knife Bezier shape makers
  2.  
  3. """
  4.  
  5. # THIS FILE IS PROTECTED BY THE GNU GENERAL PUBLIC LICENCE
  6. # FOUND IN FILE "COPYING.TXT"
  7.  
  8. ########################################################
  9. #
  10. #                          Caulk Plugin
  11. #                          v1.0, Jan 2003
  12. #                      works with Quark 6.3
  13. #
  14. #
  15. #                    by tiglari@planetquake.com
  16. #
  17. #   You may freely distribute modified & extended versions of
  18. #   this plugin as long as you give due credit to the QuArK
  19. #   Community. (It's free software, just like Quark itself.)
  20. #
  21. #   Please notify bugs & improvements to tiglari@planetquake.com
  22. #   or http://groups.yahoo.com/group/quark-python
  23. #
  24. ###
  25. ##########################################################
  26.  
  27. #$Header: /cvsroot/quark/runtime/plugins/mapcaulk.py,v 1.2 2003/01/31 20:17:44 tiglari Exp $
  28.  
  29. Info = {
  30.    "plug-in":       "Caulk plugin",
  31.    "desc":          "Caulking tthings",
  32.    "date":          "Jan 26 2003",
  33.    "author":        "tiglari",
  34.    "author e-mail": "tiglari@planetquake.com",
  35.    "quark":         "Version 6.3" 
  36. }
  37.  
  38. #
  39. # FIXME: this plugin should incorporate the contents of mb2caulk.py,
  40. #  which should be abolished, since the workings of this plugin are
  41. #  triggered by the presence of a CaulkTexture in the game config,
  42. #  whereas the other one is triggered less soundly, by the presence
  43. #  of patch-support.  The change should be made in the main branch,
  44. #  but not in 6.3, at least yet.
  45. #
  46.  
  47. import quarkx
  48. import quarkpy.mapentities
  49. import tagging
  50. from quarkpy.maputils import *
  51.  
  52. #
  53. # Caulk all-but-selected faces of poly
  54. #
  55.  
  56.  
  57. def polymenu(o, editor, oldmenu=quarkpy.mapentities.PolyhedronType.menu.im_func):
  58.     menu = oldmenu(o, editor)
  59.     caulk = quarkx.setupsubset()["DefaultTextureCaulk"]
  60.     if caulk is not None:
  61.     
  62.         #
  63.         # try to find the texture-selection menu-item, in order
  64.         #  to put the caulker after it
  65.         #
  66.         for item in menu:
  67.             try:
  68.                 if item.text == "&Texture...":
  69.                     texitem = item
  70.             except (AttributeError):
  71.                 pass
  72.                 
  73.         def applyCaulk(m,o=o,editor=editor):
  74.             tagged = tagging.gettaggedfaces(editor)
  75.             #
  76.             # FIXME: gettaggedfaces should return [] if nothing is tagged
  77.             #
  78.             if tagged==None:
  79.                 tagged=[]
  80.             debug('tagged: %s'%tagged)
  81.             sellist = editor.layout.explorer.sellist + tagged
  82.             undo = quarkx.action()
  83.             for face in o.faces:
  84.                     debug('face: %s'%face.name)
  85.                     if not face in sellist:
  86.                         undo.setspec(face,'tex',CaulkTexture())
  87.             editor.ok(undo,'Caulk poly')
  88.             
  89.         caulkItem = qmenu.item('Caulk non-selected',applyCaulk,"|Caulk texture faces that aren't selected or tagged")
  90.         #
  91.         # fancy Python list-management to put the item where we want it
  92.         #
  93.         menu.insert(menu.index(texitem)+1,caulkItem)
  94.     
  95.     return menu
  96.  
  97. quarkpy.mapentities.PolyhedronType.menu=polymenu
  98.  
  99.  
  100. def facemenu(o, editor, oldmenu=quarkpy.mapentities.FaceType.menu.im_func):
  101.     menu = oldmenu(o, editor)
  102.     caulk = quarkx.setupsubset()["DefaultTextureCaulk"]
  103.     if caulk is not None:
  104.  
  105.         def applyCaulk(m, o=o, editor=editor):
  106.             undo = quarkx.action()
  107.             undo.setspec(o,'tex',CaulkTexture())
  108.             editor.ok(undo, 'caulk face')
  109.             
  110.         for item in menu:
  111.             try:
  112.                 debug(`item.label`)
  113.             except (AttributeError):
  114.                 pass
  115.                 
  116.         texpop = findlabelled(menu,'texpop')
  117.         caulkItem = qmenu.item('Caulk face',applyCaulk,"|Put caulk texture on the face")
  118.         texpop.items.append(caulkItem)
  119.  
  120.     return menu
  121.  
  122. quarkpy.mapentities.FaceType.menu=facemenu
  123.  
  124. #
  125. # Log: #
  126.